package com.mew.lobby.handler.sys;

import com.mew.common.dc.redis.UserProfileRedisService;
import com.mew.common.entity.sys.Bulletin;
import com.mew.common.rest.bo.MewSession;
import com.mew.lobby.annotation.LobbyHandler;
import com.mew.lobby.message.response.BulletinsResponseMessage;
import com.mew.lobby.net.LobbyHandlerMapCmdType;
import com.mew.lobby.net.MewHandler;
import com.mew.lobby.provide.SysFeignService;
import com.zebra.remoting.config.EmptyMessage;
import com.zebra.remoting.protocol.ZebraCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@Slf4j
@LobbyHandler(LobbyHandlerMapCmdType.Bulletin)
public class BulletinHandler implements MewHandler<EmptyMessage> {

    @Autowired
    private SysFeignService sysFeignService;
    @Autowired
    private UserProfileRedisService userProfileRedisService;

    @Override
    public void handle(ZebraCommand<EmptyMessage> zebraCommand, MewSession session) {
        List<Bulletin> bulletins = sysFeignService.bulletins(zebraCommand.getUserId());

        BulletinsResponseMessage message = new BulletinsResponseMessage();
        message.setBulletins(bulletins);
        zebraCommand.sendMessage(message);

    }

}
